package com.jpf.service;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.jpf.dao.Goodsdao;
import com.jpf.demo.*;

public class GoodsService {
	Goodsdao goodsdao = null;
	public GoodsService() {
		super();
		this.goodsdao = new Goodsdao();
	}
	public boolean insert(Goods goods) {//增加
		int result = goodsdao.insert(goods);
		if (result > 0) {
			return true;
		}
		return false;
	}
	public List<Goods> queryGoods(String gname) {//根据商品名称查询
		return goodsdao.queryGoods(gname);
	}
	public Goods queryGoods(int gid) {//根据商品id查询
		return goodsdao.queryGoods(gid);
	}
	public List<Goods> queryGoods() {//查询全部
		return goodsdao.queryGoods();
	}
	public boolean updateGoods(Goods goods) {//修改
		int result = goodsdao.updateGoods(goods);
		if (result > 0) {
			return true;
		}
		return false;
	}
	public boolean deleteGoods(Integer gid) {//删除
		int result = goodsdao.deleteGoods(gid);
		if (result > 0) {
			return true;
		}
		return false;
	}
	public Page<Goods> queryPage(Integer pageSize, Integer pageNow) {//分页
		return goodsdao.queryPage(pageSize, pageNow);
	}
	public Page<Goods> queryPage(Integer pageSize, Integer pageNow,String gname) {//分页
		return goodsdao.queryPage(pageSize, pageNow,gname);
	}
}
